package com.example.cd5160866.modelrecycleview.activity;

import android.view.View;
import android.widget.ImageView;
import android.widget.Toast;

import com.example.cd5160866.modelrecycleview.R;
import com.example.cd5160866.modelrecycleview.adapter.ModelRecyclerAdapterV2;
import com.example.cd5160866.modelrecycleview.adapter.RecyclerItemViewId;
import com.squareup.picasso.Picasso;

import butterknife.BindView;
import butterknife.OnClick;

/**
 * Created by cd5160866 on 2018/6/4.
 */

@RecyclerItemViewId(R.layout.item_list)
public class MyImageViewHolder extends ModelRecyclerAdapterV2.ModelViewHolder<String> {
    @BindView(R.id.iv_item1)
    ImageView imageView;

    @OnClick(R.id.iv_item1)
    void onclick() {
        Toast.makeText(imageView.getContext(), position + " 点击~", Toast.LENGTH_SHORT).show();
    }

    private int position;

    public MyImageViewHolder(View itemView) {
        super(itemView);
    }

    @Override
    public void update(String item, ModelRecyclerAdapterV2 adapter, int position) {
        this.position = position;
        Picasso.with(adapter.getContext()).load(item).into(imageView);
    }

}